﻿using Artech.Common.Properties;
using Microsoft.Practices.Unity.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Artech.Common
{
    public static class Guard2
    {
        public static void IsStringOrValueType(object argumentValue, string argumentName)
        {
            if (argumentValue == null)
            {
                return;
            }
            bool isString = argumentValue is string;
            bool isValueType = typeof(ValueType).IsAssignableFrom(argumentValue.GetType());
            if (!(isString || isValueType))
            {
                throw new ArgumentException(ResourceUtility.Format(GeneralResources.ExceptionNotStringOrValueType), argumentName);
            }
        }

        public static void ArgumentIsValidePageSize(int pageSize, string argumentName)
        {
            if (pageSize < 1)
            {
                throw new ArgumentException(ResourceUtility.Format(GeneralResources.ExceptionInvalidPageSize), argumentName);
            }
        }

        public static void ArgumentIsValidePageIndex(int pageIndex, string argumentName)
        {
            if (pageIndex < 1)
            {
                throw new ArgumentException(ResourceUtility.Format(GeneralResources.ExceptionInvalidPageIndex), argumentName);
            }
        }
    }
}
